#region Developer's comment header
/* vwMembershipSimple.cs
 * 
 * author:    DS2171
 * copyright: DS2171
 * 
 * history:   15/11/2010, DS2171: Created.
 *
 */
#endregion
#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml.Serialization;

using Chili.Opf3;
using Chili.Opf3.Relations;


#endregion

namespace DocManagerORM.Entità
{
	/// <summary>
	/// Persistent object for the "vwMembershipSimple" table.
	/// </summary>
	[Serializable]
	[Persistent("vwMembershipSimple", Rights = PersistentRights.Load)]
	public partial class vwMembershipSimple : IObjectNotification, ISelfContainingObject, INotifyPropertyChanged, IvwMembershipSimple
	{
		#region Fields

		private Guid _userId = Guid.NewGuid();
		private Guid _applicationId = Guid.NewGuid();
		private string _email;
		private bool _isApproved;
		private bool _isLockedOut;
		private string _mobilePIN;
		private string _userName;
		private bool _isAnonymous;
		private string _loweredUserName;

		#endregion

		#region Properties

		/// <summary>
		/// This property is mapped to the "UserId" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("UserId", AllowDBNull = false)]
		public Guid UserId
		{
			get 
			{ 
				return _userId; 
			}
			set 
			{
				_userId = value;

				OnRowChanged("UserId");
			}
		}

		/// <summary>
		/// This property is mapped to the "ApplicationId" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("ApplicationId", AllowDBNull = false)]
		public Guid ApplicationId
		{
			get 
			{ 
				return _applicationId; 
			}
			set 
			{
				_applicationId = value;

				OnRowChanged("ApplicationId");
			}
		}

		/// <summary>
		/// This property is mapped to the "Email" field. Length must be between 0 and 256 characters. 
		/// Storage comment: .
		/// </summary>
		[Field("Email")]
		public string Email
		{
			get 
			{ 
				return _email; 
			}
			set 
			{
				if (value != null && value.Length > 256)
					throw new ArgumentException("Value length must be between 0 and 256 characters.");

				_email = value;

				OnRowChanged("Email");
			}
		}

		/// <summary>
		/// This property is mapped to the "IsApproved" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("IsApproved", AllowDBNull = false)]
		public bool IsApproved
		{
			get 
			{ 
				return _isApproved; 
			}
			set 
			{
				_isApproved = value;

				OnRowChanged("IsApproved");
			}
		}

		/// <summary>
		/// This property is mapped to the "IsLockedOut" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("IsLockedOut", AllowDBNull = false)]
		public bool IsLockedOut
		{
			get 
			{ 
				return _isLockedOut; 
			}
			set 
			{
				_isLockedOut = value;

				OnRowChanged("IsLockedOut");
			}
		}

		/// <summary>
		/// This property is mapped to the "MobilePIN" field. Length must be between 0 and 16 characters. 
		/// Storage comment: .
		/// </summary>
		[Field("MobilePIN")]
		public string MobilePIN
		{
			get 
			{ 
				return _mobilePIN; 
			}
			set 
			{
				if (value != null && value.Length > 16)
					throw new ArgumentException("Value length must be between 0 and 16 characters.");

				_mobilePIN = value;

				OnRowChanged("MobilePIN");
			}
		}

		/// <summary>
		/// This property is mapped to the "UserName" field. Length must be between 0 and 256 characters. Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("UserName", AllowDBNull = false)]
		public string UserName
		{
			get 
			{ 
				return _userName; 
			}
			set 
			{
				if (value == null)
					throw new ArgumentNullException("value", "Value is null.");
				if (value != null && value.Length > 256)
					throw new ArgumentException("Value length must be between 0 and 256 characters.");

				_userName = value;

				OnRowChanged("UserName");
			}
		}

		/// <summary>
		/// This property is mapped to the "IsAnonymous" field.  Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("IsAnonymous", AllowDBNull = false)]
		public bool IsAnonymous
		{
			get 
			{ 
				return _isAnonymous; 
			}
			set 
			{
				_isAnonymous = value;

				OnRowChanged("IsAnonymous");
			}
		}

		

		/// <summary>
		/// This property is mapped to the "LoweredUserName" field. Length must be between 0 and 256 characters. Mandatory.
		/// Storage comment: .
		/// </summary>
		[Field("LoweredUserName", AllowDBNull = false)]
		public string LoweredUserName
		{
			get 
			{ 
				return _loweredUserName; 
			}
			set 
			{
				if (value == null)
					throw new ArgumentNullException("value", "Value is null.");
				if (value != null && value.Length > 256)
					throw new ArgumentException("Value length must be between 0 and 256 characters.");

				_loweredUserName = value;

				OnRowChanged("LoweredUserName");
			}
		}

		#endregion

		#region IObjectNotification Members

		/// <summary>
		/// Invoked by the framework before the persistent object is populated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforePopulated(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is populated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterPopulated(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is inserted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeInsert(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is inserted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterInsert(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is updated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeUpdate(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is updated.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterUpdate(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework before the object is deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeDelete(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object is deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterDelete(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object has been marked deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnBeforeMarkDeleted(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		/// <summary>
		/// Invoked by the framework after the object has been marked deleted.
		/// </summary>
		/// <param name="e">
		/// Contain information about the state of the persistent object and the
		/// <see cref="Opf3.ObjectContext">ObjectContext</see> of the current operation.
		/// </param>
		void IObjectNotification.OnAfterMarkDeleted(ObjectNotificationEventArgs e)
		{
			// Add code here, if required. Leave empty if the event is not required.
		}

		#endregion

		#region ISelfContainingObject Members

		private ObjectInfo _objectInfo = null;

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectInfo">ObjectInfo</see> object that contains all
		/// information required to make the persistent object
		/// <see cref="Opf3.ObjectContext">independent from any ObjectContext</see>.
		/// </summary>
		/// <value>
		/// 	<see cref="Opf3.ObjectInfo">ObjectInfo</see> object that holds the status
		/// information of the persistent object.
		/// </value>
		ObjectInfo ISelfContainingObject.ObjectInfo
		{
			get { return _objectInfo; }
			set { _objectInfo = value; }
		}

		#endregion

		#region INotifyPropertyChanged Members

		/// <summary>
		/// Invokes the "PropertyChanged" event if a property has been changed and
		/// somebody subscribed the event.
		/// </summary>
		private void OnRowChanged(string propertyName)
		{
			if (PropertyChanged != null)
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

		/// <summary>
		/// Event is fired if a property of the persistent changed.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		#endregion
	}
}
